package com.meng.webconfig;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;


/**
 * filter 配置
 *
 * @author MENG
 * @version 2017/12/21
 * @see
 */

//@Configuration
public class FilterConfigurationBean
{
    /**
     * 登录过滤器注册
     *
     * @return
     */
    @Bean
    public FilterRegistrationBean loginFilterConfiguration()
    {
        FilterRegistrationBean registration = new FilterRegistrationBean();

        //注入过滤器
//        registration.setFilter(new LoginFilter());

        //拦截规则
        registration.addUrlPatterns("/*");

        //过滤器名称
        registration.setName("loginFilter");

        //单点登录登录页面路径
        registration.addInitParameter("loginUrl", "http://127.0.0.1:8888/");

        //是否自动注册 false 取消Filter的自动注册
        registration.setEnabled(false);

        //过滤器顺序
        registration.setOrder(1);

        return registration;
    }
}
